package cn.kgm.user.server.controller;

import cn.hutool.json.JSONUtil;
import cn.kgm.core.http.response.R;
import cn.kgm.user.dto.dto.UserRegisterDTO;
import cn.kgm.user.dto.entity.User;
import cn.kgm.user.server.abs.strategy.UserStrategy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Version 1.8
 * @AUTHOR: ruoyi
 * @Date: 2023-4-18 11:03
 * @Description: cn.kgm.user.controller.KapiUserController
 */
@Slf4j
@RestController
@RequestMapping("/login")
public class KapiUserController {

    @Resource
    private UserStrategy userStrategy;

    @GetMapping("/get")
    public R<String> get(@Validated User user) {
        userStrategy.get(user.getName())
                .register(UserRegisterDTO.builder()
                        .build());
        return R.success(JSONUtil.toJsonStr(user));
    }
}
